"use strict";
cc._RF.push(module, 'c1c4dW0TUxEaIaUe+wuqGAO', 'sceneMgr');
// Script/sceneMgr.ts

/*
 * @Author: your name
 * @Date: 2020-08-12 15:15:08
 * @LastEditTime: 2020-08-20 15:34:18
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \shici_demo\assets\Script\sceneMgr.ts
 */
Object.defineProperty(exports, "__esModule", { value: true });
var game_1 = require("./game/game");
var result_1 = require("./result/result");
var audioMgr_1 = require("./audioMgr");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var SceneMgr = /** @class */ (function (_super) {
    __extends(SceneMgr, _super);
    function SceneMgr() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.homeNode = null;
        _this.gameNode = null;
        _this.game = null;
        _this.resultNode = null;
        _this.result = null;
        _this.lv_progress_label = null;
        _this.audiomgr = null;
        // ==============进度条start=============================
        _this.targetNode = null;
        _this.loadingNode = null;
        _this.progressbar = null;
        _this.progressLabel = null;
        _this.comDegress = 0; // 完成度
        _this.comFlag = false; // 完成标志
        _this.proBar = null;
        _this.nowTime = 0;
        _this.allTime = 10;
        return _this;
    }
    // ==============进度条end=============================
    SceneMgr.prototype.onLoad = function () {
        /** ----进度条---- */
        this.proBar = this.progressbar.getComponent(cc.ProgressBar); // 进度条组件
        this.initTime();
        this.loadSource();
        this.comDegress = 0;
        this.comFlag = false;
        // 
        var lv = cc.sys.localStorage.getItem('lv');
        if (!lv) {
            lv = 1;
        }
        this.lv_progress_label.string = "\u5F53\u524D\u5904\u4E8E\u7B2C" + lv + "\u5173";
    };
    SceneMgr.prototype.onStartBtnClick = function (e, c) {
        this.audiomgr.playBtnClickMp3();
        var lv = cc.sys.localStorage.getItem('lv');
        if (!lv || parseInt(lv) === 2002) {
            lv = 1;
            cc.sys.localStorage.setItem('lv', 1);
        }
        this.gameNode.active = true;
        this.game.startGame(lv);
        this.homeNode.active = false;
        this.resultNode.active = false;
    };
    SceneMgr.prototype.onHomeBtnClick = function (e, c) {
        this.audiomgr.playBtnClickMp3();
        this.gameNode.active = false;
        this.resultNode.active = false;
        this.homeNode.active = true;
    };
    SceneMgr.prototype.onFinishBtnClick = function (e, c) {
        cc.game.end();
        //cc.director.end()
    };
    // ==========================进度条====================================
    SceneMgr.prototype.initTime = function () {
        this.nowTime = 0; // 当前已经过去得时间
        this.allTime = 10; // 总时间
    };
    SceneMgr.prototype.loadSource = function () {
        var _this = this;
        cc.loader.loadResDir("/", function (compCount, totalCount, item) {
            // 进度条回调
            _this.comDegress = compCount / totalCount;
        }, function (err, assets, urls) {
            if (err) {
                cc.error("load sources is err");
            }
            _this.comFlag = true;
            _this.loadingNode.active = false;
            _this.targetNode.active = true;
        });
    };
    SceneMgr.prototype.update = function (dt) {
        if (this.comFlag) {
            //
        }
        else {
            this.proBar.progress = this.comDegress;
            var now = this.comDegress * 100;
            this.progressLabel.string = parseInt(now.toString()) + "%";
        }
    };
    __decorate([
        property(cc.Node)
    ], SceneMgr.prototype, "homeNode", void 0);
    __decorate([
        property(cc.Node)
    ], SceneMgr.prototype, "gameNode", void 0);
    __decorate([
        property(game_1.Game)
    ], SceneMgr.prototype, "game", void 0);
    __decorate([
        property(cc.Node)
    ], SceneMgr.prototype, "resultNode", void 0);
    __decorate([
        property(result_1.Result)
    ], SceneMgr.prototype, "result", void 0);
    __decorate([
        property(cc.Label)
    ], SceneMgr.prototype, "lv_progress_label", void 0);
    __decorate([
        property(audioMgr_1.audioMgr)
    ], SceneMgr.prototype, "audiomgr", void 0);
    __decorate([
        property(cc.Node)
    ], SceneMgr.prototype, "targetNode", void 0);
    __decorate([
        property(cc.Node)
    ], SceneMgr.prototype, "loadingNode", void 0);
    __decorate([
        property(cc.ProgressBar)
    ], SceneMgr.prototype, "progressbar", void 0);
    __decorate([
        property(cc.Label)
    ], SceneMgr.prototype, "progressLabel", void 0);
    SceneMgr = __decorate([
        ccclass
    ], SceneMgr);
    return SceneMgr;
}(cc.Component));
exports.SceneMgr = SceneMgr;

cc._RF.pop();